{% load static %}
{% load blog_tags static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="referrer" content="origin">
    <!-- TDK and ICO -->
    <title>Editor.md, Markdown在线编辑器_TendCode</title>
    <meta name="description" content="markdown 在线编辑器，基于开源项目 editor.md">
    <meta name="keywords" content="Editor.md,Markdown,Markdown编辑器,Markdown在线编辑器,在线编辑器,开源Markdown编辑器">
    <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7/css/bootstrap.min.css">
    <script src="/static/js/jquery-3.2.1.min.js"></script>
    <script src="/static/plugins/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/static/css/backend.css">
    <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon"/>
    <link rel="shortcut icon" href="{% static 'editor/images/logos/editormd-favicon-16x16.ico' %}" type="image/x-icon"/>
    <link rel="stylesheet" href="{% static 'editor/css/editormd.min.css' %}"/>
    <style>
        label {
            color: white;
        }
    </style>

</head>
<body style="background-image: url('/static/images/article_images/hongkai.png')">


<nav class="navbar navbar-inverse navbar-fixed-top" style="margin-bottom: 0">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" style="font-size: 25px;padding-top: 20px">文章编辑页面</a>
        </div>
        <form class="navbar-form navbar-left">
            <a href="http://127.0.0.1:8000/blog/backend/" class="navbar-brand"><span>></span>上一页</a>
        </form>

    </div>
</nav>
<hr>

<div>
    <form action="" method="post">
    {% csrf_token %}
    <div class="form-group" style="padding-top: 40px;">
        <label for="" style="width: 170px;height: 32px;">作者：</label>
        <input type="text" style="width: 128.4px;height: 36px" value="{{ article.author }}" name="author">
    </div>
    <hr>
    <div class="form-group">
        <label for="" style="width: 170px;height: 32px;">文章标题：</label>
        <input type="text" name="title"  style="width: 280px;height: 36px" value="{{ article.title }}" id='title'>
    </div>
    <hr>
    <div class="form-group">
        <label for="" style="color: white">文章摘要：</label>
        <div>
            <textarea name="summary" cols="80" rows="10" id="summary">{{ article.summary }}</textarea>
        </div>
    </div>
    <hr>
    <div>
        <label for="">文章内容：</label><br>
        <div id="test-editormd">
            <textarea style="display:none;padding-top: 20px" name="body" id="body">
                {{ article.body }}
            </textarea>
        </div>
    </div>
    <hr>
    <div>
        <div class="form-group">
            <label for="" style="width: 170px;height: 32px">图片地址：</label>
            <input type="text" name="img_link"  style="width: 280px;height: 36px" value="{{ article.img_link }}" id='img_link'>
        </div>
        <hr>
        <div class="form-group">
            <label for="" style="width: 170px;height: 32px">喜爱量：</label>
            <input type="text" name="loves"  style="width: 280px;height: 36px" value="{{ article.loves }}" id='loves'>
        </div>
        <hr>
        <div class="form-group">
            <label for="" style="width: 170px;height: 32px">slug：</label>
            <input type="text" name="slug"  style="width: 280px;height: 36px" value="{{ article.slug }}" id='slug'>
        </div>
        <hr>
        <div class="form-group">
            <label for="" style="width: 170px;height: 32px">文章分类：</label>
            <select name="category">
                {% get_bigcategory_list as bigcategory %}
                {% for big in bigcategory %}
                    {% get_category_list big.id as cate %}
                    {% for c in cate %}
                        {% if c.id == article.category.id %}
                            <option selected value="{{ c.id }}">{{ c.name }}</option>
                        {% else %}
                            <option value="{{ c.id }}">{{ c.name }}</option>
                        {% endif %}
                    {% endfor %}
                {% endfor %}

            </select>
        </div>
        <hr>
        <div class="form-group">
            <label for="" style="width: 170px;height: 32px">标签：</label>
            <select name="tags" id="" multiple>
                {% get_tag_list as tags %}
                {% for tag in tags %}
                    {% if tag in article.tags.all %}
                        <option selected value="{{ tag.id }}">{{ tag.name }}</option>
                    {% else %}
                        <option value="{{ tag.id }}">{{ tag.name }}</option>
                    {% endif %}
                {% endfor %}
            </select>
        </div>
        <hr>
{#        <div class="form-group">#}
{#            <label for="" style="width: 170px;height: 32px">文章关键词：</label>#}
{#            <select name="keywords" multiple>#}
{#                {% get_keywords_list as keys %}#}
{#                {% for k in keys %}#}
{#                    {% if k in article.keywords.all %}#}
{#                        <option selected value="{{ k.id }}">{{ k.name }}</option>#}
{#                    {% else %}#}
{#                        <option value="{{ k.id }}">{{ k.name }}</option>#}
{#                    {% endif %}#}
{#                {% endfor %}#}
{##}
{#            </select>#}
{#        </div>#}
{#        <hr>#}
    </div>
<div>
    <input type="submit" class="btn btn-info pull-left sub_btn" style="width: 60px;height: 46px;" value="保存">
</div>
</form>
</div>
{#<input type="button" class="btn btn-info pull-right sub_btn" onclick="edit_article" value="提交">#}


</body>


<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'editor/js/editormd.min.js' %}"></script>
<script type="text/javascript">
    $(function () {
        testEditor = editormd("test-editormd", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "{% static 'editor/lib/' %}",
        });


    });

</script>
</body>
</html>
